package com.common.convert;

import com.common.convert.param.FormatParam;
import org.jodconverter.core.document.DefaultDocumentFormatRegistry;
import org.jodconverter.core.document.DocumentFormat;

import java.io.File;
import java.util.List;
import java.util.Set;

public interface Converter<T> {
    default String convert(T input, String outType){
        return convert(input , outType , null) ;
    }

    String convert(T input, String outType , List<FormatParam> params);

    default DocumentFormat getFormat(File file) {
        String fileName = file.getName();
        String fileType = getType(fileName);
        return DefaultDocumentFormatRegistry.getFormatByExtension(fileType);
    }

    default String getType(String fileName) {
        return fileName.substring(fileName.lastIndexOf(".") + 1);
    }

    Set<FormatSupport> supports();
}
